package com.oa.service.impl;

import com.oa.beans.Menu;
import com.oa.mapper.MenuMapper;
import com.oa.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 杨浩军
 * @version v1.0
 * @dateTime 2025/3/10 14:40
 */
@Service
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    public List<Menu> getMenuTree() {
        /*List<Menu> rootMenus = menuMapper.findRootMenus(); // 查询所有根菜单
        return buildMenuTree(rootMenus);*/
        return menuMapper.findRootMenus();
    }

    /*private List<Menu> buildMenuTree(List<Menu> menus) {
        for (Menu menu : menus) {
            if (menu.getIsOpen() == 1) { // 如果菜单需要展开
                List<Menu> children = menuMapper.findChildrenByParentId(menu.getMenuId()); // 查询子菜单
                menu.setChildren(children);
                if (!children.isEmpty()) {
                    buildMenuTree(children); // 递归构建子菜单
                }
            }
        }

        return menus;
    }*/

}
